/**
 * 获取某年某月份一共多少天，并返回日期列表 格式为03-23
 * @param {string} year
 * @param {string} month
 * @returns {Array}
 */
interface GetDaysInMonth {
  (year: string, month: string): string[];
}

function formatNumber(num: number): string {
  return num < 10 ? `0${num}` : `${num}`;
}

const getDaysInMonth: GetDaysInMonth = function (year, month) {
  let date = new Date(parseInt(year), parseInt(month), 1);
  let daysCount = new Date(date.getTime() - 864e5).getDate();
  let dayArr: string[] = [];
  for (let index = 0; index < daysCount; index++) {
    dayArr.push(`${formatNumber(parseInt(month))}-${formatNumber(index + 1)}`);
  }
  return dayArr;
};

export default getDaysInMonth;

